package com.syher.others.structures.entity;

/**
 * @author shenyuhang
 * @date 2018/11/20.
 **/
public class TreeNode {

    private Integer value;
    private TreeNode left;
    private TreeNode right;
    /**
     * 平衡二叉树所需特性
     */
    private Integer height;

    public TreeNode(Integer value) {
        this.value = value;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public TreeNode getLeft() {
        return left;
    }

    public void setLeft(TreeNode left) {
        this.left = left;
    }

    public TreeNode getRight() {
        return right;
    }

    public void setRight(TreeNode right) {
        this.right = right;
    }

    public boolean hasLeft() {
        return left != null;
    }

    public boolean hasRight() {
        return right != null;
    }

    public boolean isLeaf() {
        return !hasLeft() && !hasRight();
    }
}
